﻿using MadMediaManager.Core.Domain;
using NUnit.Framework;
using SharpTestsEx;

namespace MadMediaManager.DataAccess.Tests.Repositories
{
    [TestFixture]
    public class UnknownIsoRepositoryTest : BaseRepositoryTest
    {
        [Test]
        public void Test_Properties_Mapped()
        {
            var iso = UnknownIso.NewIso("path", "name", 5);
            iso.Rating = Rating.Three;
            iso.Year = 2005;
            iso.IsDeleted = true;

            iso.RowVersion.Should().Be.Null();

            DbContext.UnknownIsos.Save(iso);
            FlushAndClear();

            iso.RowVersion.Should().Not.Be.Null();

            UnknownIso found = DbContext.UnknownIsos.Get(iso.EntityId);

            found.FileSize.Unit.Should().Be.EqualTo(iso.FileSize.Unit);
            found.FileSize.Value.Should().Be.EqualTo(iso.FileSize.Value);
            found.Name.Should().Be.EqualTo(iso.Name);
            found.Rating.Should().Be.EqualTo(iso.Rating);
            found.Year.Should().Be.EqualTo(iso.Year);
            found.IsoType.Should().Be.EqualTo(iso.IsoType);
            found.RowVersion.Should().Have.SameSequenceAs(iso.RowVersion);
            found.IsDeleted.Should().Be.EqualTo(iso.IsDeleted);
        }
    }
}
